home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////
- //
- // StarBar V2.00 (!)1996 Larry Monte / StarLab Systems SoftWare
- //
- // MEX: Copyright 1990, 1995 by Lanius Corporation. All rights reserved.
- //
-
- #define INCL_starbar
-
- #include <max.mh>
- #include <starbar.mh>
- #include <language.mh>
-
- struct _ffind: ff; // Struct for raw file info
-
- struct _fileinfo // Struct for holding file info
- {
- string: fname;
- string: size;
- string: date;
- string: description;
- string: tagged;
- };
-
- array [1..60] of struct _fileinfo: finfo; // Maximum 60 lines per page
-
- int: command_line;
- char: nonstop;
-
- void no_access(ref int: pageno) // No Access to TAG/DL function
- { // notice...
- print(AVATAR_CLS+str_st_no_access);
- menu_cmd(106,"");
- pageno := pageno -1;
- }
-
- void low_light(int: count) // Remove LightBar
- {
- print(AVATAR_GOTO,(char)(count),(char)1);
- print(LO_FILENAME+ strpad(finfo[count].fname,14,' '));
- print(LO_FILESIZE+ finfo[count].size+" ");
- print(LO_FILEDATE+ finfo[count].date);
- }
-
- void high_light(int: count) // Place LightBar
- {
- print(AVATAR_GOTO,(char)(count),(char)1);
- print(HI_FILENAME+ strpad(finfo[count].fname,14,' '));
- #ifdef HILIGHT_ALL
- print(HI_FILESIZE+ finfo[count].size+" ");
- print(HI_FILEDATE+ finfo[count].date);
- #endif
- }
-
- void clear_status() // Clear status lines
- {
- print(AVATAR_GOTO,(char)(MAX_LINES-3),(char)1);
- print(AVATAR_CLEOL+"\n"+AVATAR_CLEOL);
- }
-
- void cleanup() // Clear out work dir
- {
- if(filefindfirst(ff,STARBAR_PATH+"temp"+this_task+"\\*.*",FA_NORMAL))
- {
- do
- {
- remove(STARBAR_PATH+"temp"+this_task+"\\"+ff.filename);
- }
- while(filefindnext(ff));
- filefindclose(ff);
- }
- }
-
- void do_footer() // Print command footer
- {
- string: line, area;
-
- area := COL_BLUE+"─┤"+COL_LCYAN+str_st_version+COL_BLUE+"├─"+
- COL_LBLUE+"Area:"+COL_GREEN+"<"+COL_YELLOW+farea.name+
- COL_GREEN+"> "+COL_LCYAN+substr(farea.descript,1,44)+COL_BLUE;
- line := strpad(area,106,'─');
- print(AVATAR_GOTO,(char)(MAX_LINES-3),(char)1,str_st_com_help);
- print("\n\n"+substr(line,1,106)+"\n");
- if(command_line = 0)
- {
- print(ST_LBRACKET+substr(KEY_EXIT,1,1)+ST_RBRACKET+str_st_com_exit+
- ST_LBRACKET+KEY_DOWN+ST_RBRACKET+str_st_com_down+
- ST_LBRACKET+KEY_UP+ST_RBRACKET+str_st_com_up+
- ST_LBRACKET+KEY_PGDN+ST_RBRACKET+str_st_com_pgdn+
- ST_LBRACKET+KEY_PGUP+ST_RBRACKET+str_st_com_pgup+
- ST_LBRACKET+KEY_TAG+ST_RBRACKET+str_st_com_tag+
- ST_LBRACKET+KEY_DL_CURR+ST_RBRACKET+
- ST_LBRACKET+substr(KEY_DL_TAG,1,1)+ST_RBRACKET+
- ST_LBRACKET+substr(KEY_VIEW,1,1)+ST_RBRACKET+
- ST_LBRACKET+substr(KEY_LIST,1,1)+ST_RBRACKET);
- command_line := 1;
- }
- else
- {
- print(ST_LBRACKET+KEY_DL_CURR+ST_RBRACKET+str_st_com_dl_curr+
- ST_LBRACKET+substr(KEY_DL_TAG,1,1)+ST_RBRACKET+str_st_com_dl_tag+
- ST_LBRACKET+substr(KEY_VIEW,1,1)+ST_RBRACKET+str_st_com_view+
- ST_LBRACKET+substr(KEY_LIST,1,1)+ST_RBRACKET+str_st_com_list);
- command_line := 0;
- }
- }
-
- int check_tag(int: count, ref int: que) // See if file is tagged
- {
- int: times, flags;
- string: filescheck;
-
- for(times:=que+1;times>-1;times:=times-1)
- {
- tag_get_name(que,flags,filescheck);
- if(strfind(filescheck,finfo[count].fname)>0)
- return 1;
- que := que -1;
- }
- return 0;
- }
-
-
- void do_help(ref int: pageno, ref int: count) // Display help
- {
- if(fileexists(STARBAR_PATH+"sbhelp"+uitostr(usr.lang)+".bbs"))
- display_file(STARBAR_PATH+"sbhelp"+uitostr(usr.lang),nonstop);
- else
- display_file(STARBAR_PATH+"sbhelp0",nonstop);
- count := 1;
- pageno := pageno -1;
- }
-
- void do_pgup(ref int: pageno)
- {
- if(pageno > 2)
- pageno := pageno -2;
- return;
- }
-
- int do_down(long: page_value, ref int: pageno, ref int: count,
- long: dat_file_size)
- {
- if(count < (MAX_LINES-3))
- {
- low_light(count);
- count := count +1;
- while(finfo[count].fname = "" AND MAX_LINES-3 > count)
- count := count +1;
- if(MAX_LINES-3 = count)
- {
- if(page_value = dat_file_size)
- {
- while(finfo[count].fname = "")
- count := count -1;
- high_light(count);
- return 0;
- }
- return 1;
- }
- if(finfo[count].fname = "")
- {
- count := count -1;
- high_light(count);
- }
- else
- high_light(count);
- }
- return 0;
- }
-
- int do_up(ref int: pageno, ref int: count)
- {
- if(pageno > 1)
- {
- if(count <= 1 AND pageno > 2)
- {
- count := 1;
- pageno := pageno -2;
- return 1;
- }
- if(pageno >=2 AND count > 1)
- {
- low_light(count);
- count := count -1;
- while(finfo[count].fname = "")
- count := count -1;
- if (count <= 1)
- count := 1;
- high_light(count);
- }
- }
- return 0;
- }
-
- int do_tag(ref int: pageno, int: count) // Tag/DeTag functions
- {
- int: que, quelim;
-
- if(privok(ACCESS) = FALSE)
- {
- no_access(pageno);
- return 1;
- }
- que := tag_queue_size()-1;
- quelim := que;
- if(que >= 0)
- {
- if(check_tag(count,que)=1)
- {
- tag_dequeue_file(que);
- finfo[count].tagged := " ";
- print(AVATAR_GOTO,(char)count,(char)32, finfo[count].tagged);
- clear_status();
- print(COL_WHITE+finfo[count].fname+str_st_deque);
- return 0;
- }
- }
- if(quelim >= 30)
- {
- print(AVATAR_CLS+str_st_tag_limit);
- menu_cmd(106,"");
- pageno := pageno -1;
- return 1;
- }
- clear_status();
- print(AVATAR_GOTO,(char)(MAX_LINES-4),(char)1);
- input := "A;"+finfo[count].fname;
- menu_cmd(512,"");
- que := tag_queue_size() -1;
- if(check_tag(count,que)=1)
- {
- finfo[count].tagged := ST_TAG;
- print(AVATAR_GOTO,(char)count,(char)32, finfo[count].tagged);
- }
- return 0;
- }
-
- void do_list(ref int: pageno, ref int: count) // List/Edit Tagged files
- {
- if(privok(ACCESS) = FALSE)
- {
- no_access(pageno);
- return;
- }
- input := "L;";
- print(AVATAR_CLS);
- menu_cmd(512,"");
- count := 1;
- pageno := pageno -1;
- return;
- }
-
- int do_download(ref int: pageno, ref int: count, int: ch)
- {
- int: checkdl;
-
- #ifdef DO_LOCAL_DL
-
- int: qsize, fnum, ok, flags, pos;
- string: filescheck, rootname, added_filename, new_path, out_path;
-
- #endif
-
- if(privok(ACCESS) = FALSE)
- {
- no_access(pageno);
- return 0;
- }
- print(AVATAR_CLS);
- if(ch = '\r')
- {
- if(finfo[count].size = str_st_file_offline1)
- {
- print(COL_YELLOW+finfo[count].fname+str_st_file_offline2);
- menu_cmd(106,"");
- pageno := pageno -1;
- return 0;
- }
- if(strfind(finfo[count].tagged, "+")=0)
-
- {
- print(str_st_include_enter+finfo[count].fname);
- print(str_st_include_dl);
- checkdl := input_list("|NY",0,"","","");
- if(checkdl = 'Y')
- {
- input := "A;"+finfo[count].fname;
- menu_cmd(512,"");
- }
- if(checkdl = 'N' OR checkdl = '|' AND tag_queue_size()<=0)
- {
- print(AVATAR_CLS);
- return 1;
- }
- }
- }
- if(usr.help < 6)
- {
- print(str_st_cont_dl+str_st_cancel_dl+str_st_edit_dl);
- }
-
- #ifdef DO_LOCAL_DL
-
- if (id.local = TRUE)
- {
- while (ok = 0)
- {
- qsize := (tag_queue_size());
- print(str_st_dlf,qsize+1,str_st_dlf_end);
- input_str(added_filename, INPUT_WORD,0,12,"");
- if (added_filename <> "" AND added_filename <> "/q")
- {
- input := "A;"+added_filename;
- menu_cmd(512,"");
- }
- else if (tag_queue_size() > 0 AND added_filename <> "/q")
- {
- print(str_st_alt_path);
- input_str(new_path,INPUT_WORD,0,80,"");
- if (new_path <> "")
- out_path := new_path;
- else
- out_path := LOCAL_DL_PATH;
- qsize := (tag_queue_size());
- for (fnum := 0; fnum < qsize; fnum := fnum +1)
- {
- tag_get_name( fnum, flags, filescheck);
- pos := strridx(filescheck, 0, '\\');
- if (pos=0)
- rootname := filescheck;
- else
- rootname := substr(filescheck, pos+1, strlen(filescheck)-pos+1);
- filecopy(filescheck,out_path+rootname);
- }
- input := "C;|";
- menu_cmd(512,"");
- ok := 1;
- }
- else
- ok := 1;
- }
- }
- else
-
- #endif
-
- menu_cmd(505,"");
- return 1;
- }
-
- #ifdef DO_VIEW
-
- int do_see_txt(string: work_path) // For examining files within the
- { // archive
- int: file_index, in_num, see_more;
- string: in;
- array [1..100] of string: arc_fname;
-
- file_index := 0;
- reset_more(nonstop);
-
- print(AVATAR_CLS,str_st_file_hdr);
- if(filefindfirst(ff,work_path+"\\*.*",FA_NORMAL))
- {
- do
- {
- if(strfind(ff.filename,".DOC") OR strfind(ff.filename,".TXT") OR
- strfind(ff.filename,".PRN") OR (strfind(ff.filename,"READ") AND
- strfind(ff.filename,"ME")))
- {
- file_index := file_index +1;
- arc_fname[file_index] := ff.filename;
- print(COL_LBLUE, file_index, " - "+COL_YELLOW+
- strpad(arc_fname[file_index],14,' ')+
- COL_GREEN+longpadleft(ff.filesize,9,' ')+"\n");
- }
- }
- while(filefindnext(ff) AND do_more(nonstop,COL_CYAN));
- filefindclose(ff);
- }
- if(file_index = 0)
- {
- print(str_st_no_files);
- menu_cmd(106,"");
- return 0;
- }
- print(str_st_see_cont);
- input_str(in,INPUT_NLB_LINE,0,3,"");
- in_num := strtoi(in);
- if(in_num <> 0)
- {
- print(AVATAR_CLS);
- display_file(work_path+"\\"+arc_fname[in_num],nonstop);
- see_more := input_list("YN",0,"","",str_st_see_another);
- if(see_more = 'y' OR see_more = 'Y')
- return 1;
- }
- return 0;
- }
-
- void do_desc(int: count, ref int: pageno) // FILE_ID.DIZ/SDN.ID grabbing
- { // routine
- int: again, pos, i;
- char: see_txt;
- string: work_path, temp_desc_line, desc_line;
-
- work_path := STARBAR_PATH+"temp"+this_task;
-
- print(AVATAR_CLS+str_st_hold_on);
- cleanup();
- filecopy(farea.downpath+finfo[count].fname, work_path+"\\"+finfo[count].fname);
-
- #ifdef DOS
-
- shell(IOUTSIDE_DOS|IOUTSIDE_REREAD, STARBAR_PATH+"getdesc.bat "+
- work_path+" "+work_path+"\\"+finfo[count].fname);
-
- #endif
- #ifdef OS2
-
- shell(IOUTSIDE_DOS|IOUTSIDE_REREAD, STARBAR_PATH+"getdesc.cmd "+
- work_path+" "+work_path+"\\"+finfo[count].fname);
-
- #endif
-
- if(fileexists(work_path+"\\descfile.txt")=True)
- {
- display_file(work_path+"\\descfile.txt",nonstop);
- }
- else // No descriptor file, so
- { // expand FILES.BBS desc
- print(str_st_no_desc);
- pos := 1;
- if(strlen(finfo[count].description) > 79)
- {
- do
- {
- temp_desc_line := substr(finfo[count].description,pos,79);
- i := strlen(temp_desc_line);
- if(i = 79)
- {
- while(temp_desc_line[i] <> ' ' )
- i := i -1;
- }
- desc_line := substr(temp_desc_line,1, i-1);
- print(ST_COL_DESC+desc_line+"\n");
- pos := pos + (strlen(desc_line)+1);
- }
- while(pos < strlen(finfo[count].description));
- }
- else
- print(ST_COL_DESC+finfo[count].description, "\n\n");
- }
- if(finfo[count].size = str_st_file_offline1)
- {
- menu_cmd(106,"");
- pageno := pageno -1;
- return;
- }
- see_txt := input_list("|NY",0,"","",str_st_exam);
- if(see_txt = 'y' OR see_txt = 'Y')
- {
- print(AVATAR_CLS,str_st_hold_on);
-
- #ifdef DOS
-
- shell(IOUTSIDE_DOS|IOUTSIDE_REREAD, STARBAR_PATH+"content.bat "+
- work_path+" "+work_path+"\\"+finfo[count].fname);
-
- #endif
- #ifdef OS2
-
- shell(IOUTSIDE_DOS|IOUTSIDE_REREAD, STARBAR_PATH+"content.cmd "+
- work_path+" "+work_path+"\\"+finfo[count].fname);
-
- #endif
-
- while(again := do_see_txt(work_path)=1){}
- }
- cleanup();
- if(pageno > 1)
- pageno := pageno -1;
- return;
- }
-
- #endif
-
- #ifndef DO_VIEW
-
- void do_desc(int: count, ref int: pageno) // If external View options are
- { // disabled, expand FILES.BBS
- int: i, pos; // description
- string: temp_desc_line, desc_line;
-
- print(AVATAR_CLS+" "+str_st_com_view+"\n\n");
-
- pos := 1;
- if(strlen(finfo[count].description) > 79)
- {
- do
- {
- temp_desc_line := substr(finfo[count].description,pos,79);
- i := strlen(temp_desc_line);
- if(i = 79)
- {
- while(temp_desc_line[i] <> ' ' )
- i := i -1;
- }
- desc_line := substr(temp_desc_line,1, i-1);
- print(ST_COL_DESC+desc_line+"\n");
- pos := pos + (strlen(desc_line)+1);
- }
- while(pos < strlen(finfo[count].description));
- }
- else
- print(ST_COL_DESC+finfo[count].description, "\n\n");
- menu_cmd(106,"");
- pageno := pageno -1;
- }
-
- #endif
-
- int get_input(long: page_value, ref int: pageno, ref int: count,
- long: dat_file_size)
- {
- int: ok, i_key;
- int: ch;
- // Input routines
- ok := 0;
- i_key := 0;
- while(ok = 0)
- {
- print(AVATAR_GOTO, (char)(MAX_LINES-3),(char)70,
- ST_COL_INVISIBLE+AVATAR_CLEOL);
- ch := xgetch();
- if(stridx(KEY_EXIT,1,(char)ch)>0) return 1;
- else if(ch = '?')
- {
- do_help(pageno,count);
- return 0;
- }
- else if(ch = '3' OR ch = 81 OR ch = 77)
- {
- if(page_value = dat_file_size)
- i_key := i_key -1;
- else
- return 0;
- }
- else if(ch = '9' OR ch = 73 OR ch = 75)
- {
- if(pageno = 2)
- i_key := i_key -1;
- else
- {
- do_pgup(pageno);
- return 0;
- }
- }
- else if(ch = '2' OR ch = 80)
- {
- if(do_down(page_value,pageno,count,dat_file_size)=1)
- return 0;
- i_key := i_key -1;
- }
- else if(ch = '8' OR ch = 72)
- {
- if(do_up(pageno,count)=1)
- return 0;
- i_key := i_key -1;
- }
- else if(ch = ' ')
- {
- if(do_tag(pageno,count)=1)
- return 0;
- i_key := i_key -1;
- }
- else if(stridx(KEY_LIST,1,(char)ch)>0)
- {
- do_list(pageno,count);
- return 0;
- }
- else if(stridx(KEY_DL_TAG,1,(char)ch)>0 OR ch = '\r')
- {
- if(do_download(pageno,count,ch)=1)
- return 1;
- return 0;
- }
- else if(stridx(KEY_VIEW,1,(char)ch)>0)
- {
- do_desc(count,pageno);
- return 0;
- }
- else
- {
- i_key := i_key +1;
- if(i_key = 3)
- {
- do_help(pageno,count);
- return 0;
- }
- }
- }
- }
-
- int fopen(ref int: dmp_file, // Open *.DAT/*.DMP files
- ref int: dat_file,
- ref long: dat_file_size)
- {
- string: files_info_path;
-
- if(farea.filesbbs > "")
- files_info_path := substr(farea.filesbbs,1,stridx
- (farea.filesbbs,0,'.')-1);
- else
- files_info_path := farea.downpath + "files";
-
- dmp_file := open(files_info_path + ".dmp", IOPEN_READ|IOPEN_BINARY);
- if (dmp_file < 0) return(dmp_file);
-
- dat_file_size := filesize(files_info_path + ".dat");
- dat_file := open(files_info_path + ".dat", IOPEN_READ|IOPEN_BINARY);
- if (dat_file < 0)
- {
- return(dat_file);
- }
- else return(0);
- }
-
- int do_descript(int: count, int: brackets) // Print file description
- { // with word-wrapping
- int: i, pos, que;
- string: temp_desc_line1, desc_line1, desc_line2;
-
- que := tag_queue_size()-1;
-
- if(que >= 0)
- if(check_tag(count,que)=1)
- finfo[count].tagged := ST_TAG;
- else
- finfo[count].tagged := " ";
-
- if(strlen(finfo[count].description) > DESCRIPT)
- {
- temp_desc_line1 := substr(finfo[count].description,1,DESCRIPT);
- for(i:=DESCRIPT;i>0;i:=i-1)
- {
- if(temp_desc_line1[i] = ' ')
- {
- desc_line1 := substr(finfo[count].description,1, i-1);
- desc_line2 := substr(finfo[count].description,i+1,79);
- print(finfo[count].tagged+ST_COL_DESC+desc_line1);
- if(count < MAX_LINES-4)
- {
- print("\n"+strpad(" ",32+COUNT_OFFSET+brackets,' '));
- print(substr(desc_line2,1,DESCRIPT-(COUNT_OFFSET+(brackets))));
- return (count+2);
- }
- return (count+1);
- }
- }
- }
- print(finfo[count].tagged+ST_COL_DESC+finfo[count].description);
- return (count+1);
- }
-
- void display_info(int: dmp_file, int: dat_file, long: dat_file_size)
- {
- array [1..255] of long: page;
- int: file_status, dat_rec_size, brackets;
- int: count, pageno, done, i;
- long: posn; // Display file info
- unsigned long: dmp_descript_length;
- char: ff_flags;
- string: temp_dmp, counter, dat_rec, tag_char;
- struct _stamp: ul_date;
-
- read(dat_file,dat_rec,32);
- dat_rec_size := dat_rec[14];
-
- pageno := 1;
- done := 0;
- page[pageno] := 0;
-
- seek(dat_file,0,SEEK_SET);
- while(done = 0)
- {
- posn := 0;
- count := 1;
- for(i:=1;i<MAX_LINES;i:=i+1)
- {
- finfo[i].fname := "";
- finfo[i].size := "";
- finfo[i].date := "";
- finfo[i].description := "";
- finfo[i].tagged := " ";
- }
- print(AVATAR_CLS);
- while(count < (MAX_LINES-3) AND read(dat_file,dat_rec,dat_rec_size))
- {
- posn := posn +dat_rec_size;
- page[pageno+1] := seek(dat_file,page[pageno]+posn,SEEK_SET);
- finfo[count].fname := substr(dat_rec,1,stridx(dat_rec,1,0x00)-1);
- ff_flags := dat_rec[15];
- if(ff_flags & FF_OFFLINE)
- {
- finfo[count].size := str_st_file_offline1;
- finfo[count].date := "";
- }
- else
- {
- finfo[count].size := strpadleft(ultostr(hextoul(dat_rec,35)),7,' ');
- bit_date_to_stamp(hextoul(dat_rec,27),ul_date);
- finfo[count].date := substr(stamp_string(ul_date),1,9);
- }
- seek(dmp_file,hextoul(dat_rec,43),SEEK_SET);
- read(dmp_file,temp_dmp,2);
- dmp_descript_length := hextoui(temp_dmp,1);
- read(dmp_file,temp_dmp,dmp_descript_length);
- if (COUNT_OFFSET > 0)
- {
- counter := ST_COUNT_LBRACKET+strpadleft(ltostr(hextoul(dat_rec,23)),
- COUNT_OFFSET,' ')+ ST_COUNT_RBRACKET;
- brackets := 3;
- }
- finfo[count].description := counter+temp_dmp;
- low_light(count);
- count := do_descript(count,brackets);
- }
- pageno := pageno +1;
- if(page[pageno] >= dat_file_size AND count < MAX_LINES-3)
- print(str_st_end_filelist);
- while(count < MAX_LINES-4)
- {
- print("\n");
- count := count +1;
- }
- do_footer();
- count := 1;
- high_light(count);
- done := get_input(page[pageno],pageno,count,dat_file_size);
- if(page[pageno] = 0)
- seek(dat_file,0,SEEK_SET);
- else
- seek(dat_file,page[pageno]-dat_rec_size,SEEK_SET);
- }
- }
-
- void read_files()
- {
- int: dmp_file, dat_file;
- long: dat_file_size;
-
- if (fopen(dmp_file, dat_file, dat_file_size))
- {
-
- #ifdef DO_LOG // Read *.DAT/*.DMP, if not
- // exist, use internal max
- log("S"+str_st_log_no_dat); // file_titles routine
-
- #endif
-
- menu_cmd(502,"");
- return;
- }
- display_info(dmp_file, dat_file, dat_file_size);
- close(dat_file);
- close(dmp_file);
- }
-
- void main()
- {
- char: hotkeys;
-
- init_lang_starbar(); // initiate language file
-
- hotkeys := usr.hotkeys;
- if(usr.hotkeys = 0) // set hotkeys to ON
- menu_cmd(615,"");
- while(usr.def_proto = PROTOCOL_NONE) // Protocol needed
- menu_cmd(618,"");
- if((usr.video=1 OR usr.video=2) AND (strfind(usr.xkeys, KEY) = False))
- {
- #ifdef DO_LOG
- log("S"+str_st_log_using_sb);
- #endif
- read_files();
- #ifdef DO_LOG
- log("S"+str_st_log_success);
- #endif
- }
- else
- {
- #ifdef DO_LOG
- log("S"+str_st_log_using_ft);
- #endif
- menu_cmd(502,"");
- }
- usr.hotkeys := hotkeys;
- print(AVATAR_CLS);
- }
-
-
-
-
-
-
-